package com.elite.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ViewController {

	@GetMapping("/testView1")
	public ModelAndView testModelAndView1() {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("/view/hello");
		return modelAndView;
	}

	@GetMapping("/testGetView")
	public String testGetView() {

		return "/view/hello";
	}

	@GetMapping("/view/testReturnViewNull")
	public String testReturnViewNull() {

		return null;
	}

	@PostMapping("/testPostView")
	public String testPostView() {

		return "/view/hello";
	}

	@GetMapping("/testReturnNull")
	public String testReturnNull() {

		return null;
	}

	/**
	 * 测试转发
	 * @return
	 */
	@GetMapping("/testForward")
	public String testForward() {

		return "forward:/view/hello";
	}


	/**
	 * 测试重定向
	 * @return
	 */
	@GetMapping("/testRedirect")
	public String testRedirect() {

		return "redirect:http://www.baidu.com";
	}
}
